#include <iostream>
#include <cstring>
#include <unistd.h>
#include <stdlib.h>


int main()
{
  //std::cerr << "*******" << std::endl;

  char* m = getenv("METHOD_ENV");
  //std::cerr << "******" << m << std::endl;

  if(strcasecmp(m, "POST") == 0)
  {
    char buf[1024] = { 0 };
    ssize_t s = read(0, buf, 1024);
    if(s > 0)
    {
      //std::cerr << "main main post " << buf << std::endl;
      write(1, buf, s);
    }

    //std::cout << p << std::endl;
  }
  else if(strcasecmp(m, "GET") == 0)
  {
    char* param = getenv("PARAM_ENV");
    //std::cerr << "******" << param << std::endl;
    if(param)
    {
      //std::cerr << "main main get " << param << "main main " << std::endl;
      write(1, param, strlen(param));
    }
  }

  return 0;
}

